<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>笔记查询</title>
<script type="text/javascript" 
	     src="scripts/jquery.min.js"></script>
<script type="text/javascript"
		  src="scripts/basevalue.js"></script>
<script type="text/javascript"
		  src="scripts/cookie_util.js"></script>
<script type="text/javascript">
	$(function(){
		//绑定搜索按钮单击事件
		$("#btn_search").click(function(){
			//alert("绑定成功");
			//获取参数
			var userId=getCookie("userId");
			//获取标题/状态/时间
			var title=$("#title").val().trim();
			var status=$("#status").val();
			var begin=$("#begin").val().trim();
			var end=$("#end").val().trim();
			console.log(userId+","+title+","+status+","+begin+","+end);
			if(userId==null){
				window.location.href="log_in.html";
			}else{
				//发送请求
				$.ajax({
					url:path+"/note/manage.do",
					type:"post",
					data:{"title":title,"status":status,
						   "begin":begin,"end":end,
						   "userId":userId},
					dataType:"json",
					success:function(result){
						if(result.state==0){
							
							var notes=result.data;
							//清除tr
							$("table tr:gt(0)").remove();
							for(var i=0;i<notes.length;i++){
								//获取显示的数据
								var noteTitle=notes[i].title;
								var noteStatus=notes[i].statusId;
								var createTime=notes[i].createTime;
								//拼凑TR
								var str="";
								str+="<tr>";
								str+="<td><input type='checkbox'>"+noteTitle+"</td>";
								str+="<td>"+noteStatus+"</td>";
								str+="<td>"+new Date(createTime)+"</td>";
								str+="</tr>";
								//将str转换成jQuery对象
								var $tr=$(str);
								//将tr对象追加到table中
								$("table").append($tr);
							}
						}
					},
					error:function(){
						alert("搜索失败");
					}
				});
			}
		});
		
	});
	
</script>
</head>
<body>
	标题:<input type="text" id="title"/>
	状态:<select id="status">
				<option value="0">全部</option>
				<option value="1">正常</option>
				<option value="2">删除</option>
		  </select>
	开始时间:<input type="text" id="begin" />
	结束时间:<input type="text" id="end" />
	<input type="button" id="btn_search" 
			 value="搜索笔记" />
	<hr />
	<table>
		<tr><th>标题</th><th>状态</th><th>创建时间</th></tr>
	</table>
</body>
</html>





